package exception_test;

/**
 * @author yuisama
 * @date 2022/05/07 21:25
 **/
public class FinallyTest {
    public static void main(String[] args) {
//        int[] data = {1,2,3};
//        try {
//            System.out.println(data[1]);
//        }catch (ArrayIndexOutOfBoundsException e) {
//            e.printStackTrace();
//        }finally {
//            System.out.println("finally代码块~~");
//        }
//        System.out.println("异常体系之后的代码");
//        int ret = test();
//        System.out.println(ret);
        fun();
        System.out.println("after fun");
    }

    public static void fun() throws ArithmeticException{
        int[] arr = {1,2,3};
        System.out.println(arr[1]);
        throw new NullPointerException("没事干，抛个异常玩玩~~");
    }

//    public static int test() {
//        try {
//            int[] data = {1,2,3};
//            data[100] = 10;
//            return 10;
//        }catch (ArrayIndexOutOfBoundsException e) {
//            e.printStackTrace();
//            return 20;
//        }finally {
//            System.out.println("finally 代码块");
//        }
//    }
}